home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11183 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: fred.net!news
  2. From: bitmask@bigdog.fred.net (Scott Allen)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A Simple Question From A Beginner (Please Help)
  5. Date: Tue, 19 Mar 1996 13:31:56 GMT
  6. Organization: FredNet - Frederick, Md.
  7. Message-ID: <314eb48a.997688@news.fred.net>
  8. References: <4i26gm$6th@news.bellglobal.com>
  9. NNTP-Posting-Host: bitmask.fred.net
  10. X-Newsreader: Forte Agent .99d/32.168
  11.  
  12. dlowe@pathcom.com (David Lowe) wrote:
  13.  
  14. >
  15. >This should be a simple thing to execute but for some reason I can not
  16. >get it to work.
  17. >
  18. >
  19. >What I would like to do is execute something like a SHELL command.
  20. >What I would like to do in C or C++ is the equivelent to typing the
  21. >following at the Win NT command line:
  22. >
  23. >
  24. >    sendmail dlowe@pathcom.com < mail.txt
  25. >
  26. >I have tried the following code:
  27. >
  28. >   _spawnl( _P_WAIT, "sendmail.exe", "dlowe@pathcom.com < mail.txt", 
  29. >             NULL);   
  30.  
  31. Dave, 
  32.  
  33. Remember in spanwl you need to pass the 
  34. mode, path, and arg0 before you pass 
  35. any of the other command line arguments.
  36. So perhaps it should look more like this :
  37.  
  38. spawnl(P_WAIT, "sendmail.exe", "sendmail.exe", arg1, NULL );
  39.  
  40. You might want to check the return value against ENOENT
  41. to see if the program/path not found. I'm not sure how
  42. your specific implementation works, you might need to
  43. give the specific path to sendmail. Perhaps using 
  44. the searchpath function (in BC++ anyway).
  45.  
  46. Hopwe this helps, 
  47. --
  48.        Scott Allen             
  49.   bitmask@bigdog.fred.net      
  50.     Hagerstown, MD USA         
  51.